/*
							Copyright (C) 2010  Alourien Team
									
						This file is part of the Alourien Engine.

    The Alourien Engine is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    The Alourien Engine is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with the Alourien Engine.  If not, see <http://www.gnu.org/licenses/>.
	
*File Name: MathClassImp.cpp
*Programmer Name:Jose Castellano
*Date of last update:10/18/2010
*
*Purpose:This Program is to provide all the math that is required in any type
* of computation for our game.
*
*Basic Info: This file includes finding the distance, the pythagorean theorum,
* the quadratic formula, and more eventually.
*
*UPDATES:
*1) Added the quadratic formula to the list
*   Date: 10/4/2010 Updater: Jose Castellano
*
*2) Added the actual code to our Engine namespace
*   Date: 10/06/2010 Updater: Manuel Cuellar
*
*3) Added the overloads to some functions to help in the lessening of includes
*   Date: 10/18/2010 Updater: Jose Castellano
*
*
*
*/

#include "MathClass.h"
#include <math.h>

namespace Alourien
{
	MathClass::MathClass(void)
	{
	}


	MathClass::~MathClass(void)
	{
	}

	//Distance formula uses the sqrt function from Math.h
	float MathClass::Distance(float x1, float y1, float x2, float y2)
	{
		return (float)sqrt(pow((float)(x2-x1),2) + pow((float)(y2-y1),2));
	}

	//The pythagorean Theorem, same as distance kind of
	float MathClass::PythagoreanTheorem(float a, float b)
	{
		return (float)sqrt(pow(a,2) + pow(b,2));
	}

	//Quadractic formula, could help in the projection of things
	float MathClass::QuadraticFormulaPlus(float a, float b, float c)
	{
		float x;

		x = 0-b;
		x += (float)sqrt((pow(b,2) - (float)(4 * a * c)));
		x = x /(float)(2*a);

			return x;
	}

	//Quadractic formula, could help in the projection of things
	float MathClass::QuadraticFormulaMinus(float a, float b, float c)
	{
		float x;

		x = 0-b;
		x -= (float)sqrt((pow(b,2) - (float)(4 * a * c)));
		x = x /(float)(2*a);

			return x;
	}
	
	//Overloaded sqrt function so I could do the check and not have to
	// include the math.h
	float MathClass::Sqrt(float value)
	{
		if(value < 0)
		{
			return 0;
		}
		else
		{
			return (float)sqrt(value);
		}
	}
	
	//Overloaded pow function so I could do the check and not have to
	// include the math.h
	float MathClass::Pow(float value, float power)
	{
		return (float)pow(value,power);
	}
	
	//Overload of the trig functions so I wouldn't have to include the
	// math.h file along with this one.
	float MathClass::Sin(float value)
	{
		return (float)sin(value);
	}
	float MathClass::Cos(float value)
	{
		return (float)cos(value);
	}
	float MathClass::Tan(float value)
	{
		return (float)tan(value);
	}
}
